'use strict';
	angular.module('accounting.periodCaptionNext', [])

	.controller('periodCaptionNextCtrl',['$rootScope', '$scope' , f])
    function f($rootScope, $scope) {

		var Model = this;
		
		//获取会计现行年月
	    Model.getInfo = function(){
	    	$.LoadingOverlay("show");
			$.ajax({
	            type: "GET",
	            async : true,//异步（默认），同步为false
	            url: $rootScope.getProjectName() + "/accounting/paramSetting/getInfo",
	            data: {},
	            contentType: "application/json; charset=utf-8",
	            dataType: "json",
	            success: function (data) {
	            	$.LoadingOverlay("hide");
	                // Play with returned data in JSON format
					console.log('data->',data);
					if(data.code==0){
						$scope.dataConfigure = data.data;
						$scope.$apply();
					}else{
						alert(data.info);
					}
	            },
	            error: function (msg) {
	            	$.LoadingOverlay("hide");
	                alert('ajax调用错误信息：'+msg.responseText);
	            }
	        });
	    };
	    
	    Model.getInfo();
		
	    Model.next = function(){

	    	var options = {};
	    	options.yearPeriodNo = $scope.dataConfigure.kjxxny;
	    	
			$.ajax({
	            type: "POST",
	            async : true,//异步（默认），同步为false
	            url: $rootScope.getProjectName() + "/accounting/periodCaption/calculate/next",
	            data: JSON.stringify(options),
	            contentType: "application/json; charset=utf-8",
	            dataType: "json",
	            success: function (data) {
	                // Play with returned data in JSON format
					console.log('data->',data);
					if(data.code==0){
						Model.getInfo();
					}else{
						alert(data.info);
					}
	            },
	            error: function (msg) {
	                alert('ajax调用错误信息：'+msg.responseText);
	            }
	        });
	    };


		
		return Model;
	}	
	
